package com.yupi.springbootinit.config;

import io.swagger.models.auth.In;
import lombok.Data;
import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author: wenjupeng
 * @Date: 2025/02/13/11:05
 * @Description:
 * @Param:
 * @return:
 */
@Configuration
@ConfigurationProperties(prefix = "spring.redis")
@Data
public class RedissonConfig {
   private Integer database;
   private String host;
   private Integer port;
   private String password;
   @Bean
    public RedissonClient redissonClient(){
       Config config = new Config();
       config.useSingleServer()
               .setDatabase(database)
               .setAddress("redis://"+host+":"+port);
               //.setPassword(password);
       RedissonClient redisson = Redisson.create(config);
       return redisson;
    }
}
